#ifndef TD_BASE_SHOT_H_
#define TD_BASE_SHOT_H_

/************************************************************************/
/* Core                                                                 */
/************************************************************************/
#include "Core/BaseEntity.h"

/************************************************************************/
/* GAME                                                                 */
/************************************************************************/
#include "Game/Managers/MarioManager.h"


namespace TD_Game {


	class BaseShot : public BaseEntity {
		
		/************************************************************************/
		/* Default values                                                       */
		/************************************************************************/
		static const float defaultVelocity;
		static const unsigned int defaultShotDamage;
		static const float shotCollisionThreshold;
		
		/** Shot states.*/
		typedef enum {
			moving,
			exploding,
			finished
		} shotStates;


		/** Current shot state.*/
		shotStates m_currShotState;
		bool m_hittedTarget;

		/************************************************************************/
		/* Private functions                                                    */
		/************************************************************************/

		void processStates();

	protected:

		/** Shot properties: */
		/** Shot velocity. */
		float m_maxVelocity;
		/** Shot dmg */
		unsigned int m_shotDamage;
		
		/** The target mario that the shot was fired.*/
		const BaseMario *m_pTargetMario;
		unsigned int m_marioID;
		Coord2D m_marioPosition;

		/** Shot animation set.*/
		AnimationSet *m_pAnimationSet;

		/************************************************************************/
		/* Protected functions		                                               */
		/************************************************************************/
		virtual void hitTarget() = 0; 

	public:

		/************************************************************************/
		/* ctors and dtors                                                      */
		/************************************************************************/

		//Default
		explicit BaseShot();

		//Copy
		explicit BaseShot(const BaseShot &rhs);
		
		//Assignment
		BaseShot & operator=(const BaseShot &lhs);

		//Initialization
		explicit BaseShot(const Coord2D &initialPosition, unsigned int g_shotDamage, const BaseMario *targetMario, unsigned int marioID);

		~BaseShot();

		
		
		/************************************************************************/
		/* Access functions                                                     */
		/************************************************************************/
		const Coord2D & getTargetPosition() const {
			return(m_marioPosition);
		}

		inline float getDistanceToTarget() const {
			return(Coord2D::DistanceBetween(m_marioPosition, m_position));
		}

		inline bool isFinished() const {
			if(m_currShotState == finished) {
				return true;
			}
			return false;
		}

		/************************************************************************/
		/* Functionalities                                                      */
		/************************************************************************/
		void update(unsigned int deltaTime);
		void render(SDL_Surface *const g_destSurface, unsigned int deltaTime);

	};
}
#endif